<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('品牌信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>订单编号：</label>
                            <input type="text" name="company"/>
                        </li>
                        <li>
                            <label>客户姓名：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li class="select-time">
                            <label>订购时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]" lay-key="1">
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]" lay-key="2">
                        </li>
                        <li class="select-time">
                            <label>金额： </label>
                            <input type="text" class="" id="beginMoney" placeholder="最小金额" name="params[beginMoney]" lay-key="1">
                            <span>-</span>
                            <input type="text" class="" id="endMoney" placeholder="最大金额" name="params[endMoney]" lay-key="2">
                        </li>
                        <li>
                            <label>审核状态：</label>
                            <select name="chkStatus">
                                <option value="">请选择</option>
                                <option value="0">未审核</option>
                                <option value="1">审核中</option>
                                <option value="2">审核通过</option>
                                <option value="3">审核不通过</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="market:order:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="market:order:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="market:order:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="market:order:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('market:order:edit')}]];
    var detailFlag = [[${@permission.hasPermi('market:order:detail')}]];
    var detail2Flag = [[${@permission.hasPermi('market:order:detail2')}]];
    var assignFlag = [[${@permission.hasPermi('market:order:assign')}]];
    var deleteFlag = [[${@permission.hasPermi('market:order:remove')}]];
    var prefix = ctx + "market/order";

    function numFormat(num) {
        var c = (num.toString().indexOf ('.') !== -1) ? num.toLocaleString() : num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
        return c;
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            orderEditUrl: prefix + "/edit/{orderIndent}",
            orderDetailUrl: prefix + "/detail/{orderIndent}",
            orderDetailUrl2: prefix + "/detail2/{orderIndent}",
            orderAssignUrl: prefix + "/assign/{orderIndent}",
            delete1Url: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单信息",
            columns: [{
                checkbox: true
            },
                {
                    title: '序号',
                    formatter:function (value,row,index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'orderIndent',
                    title: '订单编号'
                },
                {
                    field: 'customer.name',
                    title: '客户姓名'
                },
                {
                    field: 'customer.telephone',
                    title: '联系电话'
                },
                {
                    field: 'orderTime',
                    title: '订购时间'
                },
                {
                    field: 'orderMoney',
                    title: '金额',
                    formatter:function (value) {
                        var rmb='￥';
                        if (value!=null){
                            return rmb+numFormat(value);
                        }
                    }
                },
                {
                    field: 'sysOperUserId',
                    title: '操作人'
                },
                {
                    field: 'chkStatus',
                    title: '审核状态',
                    formatter:function(value){
                        if (value==0){
                            return "未审核";
                        }
                        if (value==1){
                            return "审核中";
                        }
                        if (value==2){
                            return "审核通过";
                        }
                        if (value==3){
                            return "审核不通过";
                        }
                    }
                },
                {
                    field: 'sysChkUserId',
                    title: '审核人'
                },
                {
                    field: 'checkTime',
                    title: '审核时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.chkStatus==0){
                            actions.push('<a class="btn btn-outline btn-danger ' + assignFlag + '" href="javascript:void(0)" onclick="$.operate.orderEdit1(\'' + row.orderIndent + '\')" ><i class="fa fa-check"></i>提交审核</a> ');
                        }
                        if (row.chkStatus==2){
                            actions.push('<a class="btn btn-outline btn-warning ' + detail2Flag + '" href="javascript:void(0)" onclick="$.operate.orderDetail2(\'' + row.orderIndent + '\')" ><i class="fa fa-paste"></i>出库详情</a> ');
                        }
                        if (row.chkStatus==0){
                            actions.push('<a class="btn btn-outline btn-danger ' + deleteFlag + '" href="javascript:void(0)" onclick="$.operate.delete1(\'' + row.orderIndent + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        if (row.chkStatus==0||row.chkStatus==3){
                            actions.push('<a class="btn btn-outline btn-success ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.orderEdit(\'' + row.orderIndent + '\')"><i class="fa fa-edit"></i>修改</a> ');
                        }

                        actions.push('<a class="btn btn-outline btn-info ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.orderDetail(\'' + row.orderIndent + '\')" ><i class="fa fa-paste"></i>订单详情</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
<script>
    $(function () {
        $.get("/common/plist",'',function (data) {
            var plist="<option value=\"\">请选择省份</option>";
            $(data).each(function (i,e) {
                plist+="<option value='"+e.provId+"'>"+e.provName+"</option>";
            });
            $("#province").html(plist);
        },'json');

        $("#province").change(function () {
            var pid=$(this).val();
            $.get("/common/clist?pid="+pid,'',function (data) {
                var clist=" <option value=\"\">请选择城市</option>";
                $(data).each(function (i,e) {
                    clist+="<option value='"+e.cityId+"'>"+e.cityName+"</option>";
                });
                $("#city").html(clist);
            },"json");
        });
    });
</script>
</body>
</html>